import { ConanCardFeatureEntity } from "../../models/conan-card.model";
import { GlobalService } from "../../services/global.service";

// components/conan-card-item/conan-card-item.component.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    imgUrl: {
      type: String,
      value: ''
    },
    count: {
      type: Number,
      value: 0
    },
    cardId: {
      type: Number,
      value: 0
    },
    small: {
      type: Boolean,
      value: false
    },
    display: {
      type: Boolean,
      value: false,
    },
    featureList: {
      type: Object,
      value: {}
    },
  },

  observers: {
    'featureList': function () {
      this.setData({ features: this.data.featureList as ConanCardFeatureEntity[] });
    },
    'display': function (e) {
      console.log(e);
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    // FILE_HOST: GlobalService.FILE_HOST,
    STATIC_FILE_HOST: GlobalService.STATIC_FILE_HOST,
    detailVisible: false,
    features: [] as ConanCardFeatureEntity[],
    imgOnly: false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onIncrease: function () {
      this.triggerEvent('increase', this.data.cardId)
    },
    onDecrease: function () {
      this.triggerEvent('decrease', this.data.cardId)
    },
    detail: function () {
      this.setData({ detailVisible: true });
    },
    showImgOnly: function () {
      this.setData({ imgOnly: !this.data.imgOnly });
    },
    onVisibleChange: function (e: any) {
      this.setData({
        detailVisible: e.detail.visible,
      });
    },

  }
})